home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / util / misc / Fudgit233.lha / Source / src / fudgit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-16  |  2.1 KB  |  109 lines

  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <math.h>
  4. #include <string.h>
  5. #ifndef NOUNISTD_H
  6. #include <unistd.h>
  7. #endif
  8. #include <signal.h>
  9.  
  10. #include "fudgit.h"
  11. #include "macro.h"
  12. #include "head.h"
  13. #include "setshow.h"
  14.  
  15. int Ft_Interact = 0;
  16. char *Ft_Progname;
  17. static int initload(void);
  18.  
  19. #ifdef AMIGA
  20. long main(int c, char **v)
  21. #else
  22. void main(int c, char **v)
  23. #endif
  24. {
  25.     /****
  26.     mallopt(M_DEBUG, 1);
  27.     mallopt(M_MXFAST, 0);
  28.     ******/
  29.     Ft_initmac();
  30.     Ft_initstacks();  /* don't fool around with the order */
  31.     Ft_initparser();
  32.     Ft_initmacros();
  33.     Ft_initcode();
  34.     Ft_initsetup();
  35.     Ft_initdl();
  36.     Ft_clearpush_cwd();
  37.     signal(SIGPIPE, SIG_IGN);
  38.     signal(SIGFPE, Ft_catcher);
  39.     signal(SIGINT, Ft_catcher);
  40.     signal(SIGQUIT, Ft_catcher);
  41.     signal(SIGTSTP, Ft_catcher);
  42. #ifdef SIGBUS
  43.     signal(SIGBUS, Ft_catcher);
  44. #endif
  45.     signal(SIGHUP, Ft_catcher);
  46.     signal(SIGSEGV, Ft_catcher);
  47.     signal(SIGILL, Ft_catcher);
  48.     Ft_Interact = isatty(0);
  49.     Ft_Progname = v[0];
  50.  
  51.     if (c == 1 && Ft_Interact) {
  52.         initload();
  53. #ifndef AMIGA
  54.         Ft_initreadline();
  55. #endif
  56.         Ft_printversion();
  57.         Ft_run();
  58.     }
  59.     else {
  60.         int i;
  61.  
  62.         Ft_Interact = 0;
  63.         if (c==1) {
  64.             initload();
  65.             Ft_run();
  66.         }
  67.         else {
  68.             for (i=c-1;i>0;i--) {  /* push all the files on the I/O stack */
  69.                 Ft_pushio(v[i], AFILE, 0);
  70.             }
  71.             initload();
  72.             Ft_run();
  73.         }
  74.     }
  75.     Ft_exit(0);
  76. #ifdef AMIGA
  77.    return 0;
  78. #endif
  79. }
  80.  
  81. #include <sys/types.h>
  82. #include <sys/stat.h>
  83.  
  84. static int initload(void)
  85. {
  86.     char name[TOKENSIZE];
  87.     struct stat buf;
  88.  
  89.     sprintf(name, "%s/.fudgitrc", Ft_Home);
  90.     if (stat(name, &buf) == 0)
  91.         return(Ft_pushio(name, AFILE, 0));
  92.  
  93.     return(0);
  94. }
  95.  
  96. int Ft_printversion(void)
  97. {
  98. #ifdef AMIGA
  99.     fprintf(stderr, "\n\tF U D G I T\n\t 2.33 Amiga \n");
  100. #else
  101.     fprintf(stderr, "\n\tF U D G I T\n\tversion  %s\n\tMay 1993\n",
  102.     VERSION);
  103.     fprintf(stderr, "\tlast modified %s\n", DATE);
  104. #endif
  105.     fputs("\tCopyright (C) 1993  Martin-D. Lacasse\n", stderr);
  106.     fputs("\tSee the `Credits' and `README' help topics for more.\n\n", stderr);
  107.     return(0);
  108. }
  109.